﻿using System;
using System.Configuration;


namespace mojoPortal.Web.RS.Admin
{
    public partial class RSContactUs : RSBasePage
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //SuppressAllMenus();
            //SuppressPageMenu();
            InitializeReadyServicePage("ReadyService Support");
        }

        protected void btnSendEmail_Click(Object sender, EventArgs e)
        {
            string body = txtComment.Text;
            string subject = txtSubject.Text;
            string toEmail = txtTo.Text;
            string fromEmail = txtFrom.Text;
            if(fromEmail.Length > 0)
                SendEmail(body, subject, fromEmail, toEmail);
        }

        private void SendEmail(string body, string subject, string fromEmail, string toEmail)
        {
            System.Net.Mail.MailMessage eMail = new System.Net.Mail.MailMessage();
            eMail.IsBodyHtml = true;
            eMail.Body = body;
            eMail.From = new System.Net.Mail.MailAddress(fromEmail);
            eMail.To.Add(toEmail);
            eMail.Subject = subject;
            System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient();

            string smtpUserName = ConfigurationManager.AppSettings["SMTPUser"].ToString();
            string smtpPassword = ConfigurationManager.AppSettings["SMTPPassword"].ToString();
            string smtpServer = ConfigurationManager.AppSettings["SMTPServer"].ToString();
            SMTP.Credentials = new System.Net.NetworkCredential(smtpUserName, smtpPassword);
            SMTP.Host = smtpServer;
            SMTP.Send(eMail);
            eMail.Dispose();
            lblActionMessage.Text = "Thank you.  Your email message has been sent.";
            btnSendEmail.Enabled = false;
        }

    }
}